<?php

class Respondent {

  private $id;
  private $loadedData = array('core' => 0,
                              //'department' => 0,
                              //'devices' => 0,
                              //'product' => 0,
                              'importance' => 0,
                              'technology' => 0,
                              'time' => 0,
                              'time_strings' => 0
                              );
  private $data  = array('core' => array(),
                         //'department' => array(),
                         //'devices' => array(),
                         //'product' => array(),
                         'importance' => array(),
                         'technology' => array(),
                         'time' => array(),
                         'time_strings' => array()
                         );
  public function __construct($id = false) {
    if ($id) {
      $this->id = $id;
    }
  }

  public function addNew($data) {
  	$respondentBuilder = new RespondentBuilder();
  	$this->id = $respondentBuilder->create($data);
  }

  public function getValue($table, $field) {
  	if ($this->loadedData[$table] == 0) {
  		$db = Db::getConnection();
  		$values = $db->selectOne("SELECT * FROM `$table` WHERE id_respondent={$this->id}");
  		$this->data[$table] = $values;
  		$this->loadedData[$table] = 1;
  	}
  	return $this->data[$table][$field];
  }
  
}